package com.base.commons.tools.enums;

import lombok.Getter;

/**
 * @author zhuhecheng
 * @version 1.00
 * @time 2019/10/22 0022
 */
@Getter
public enum TimeZoneEnum {

    ZERO_0(0,"GMT 00:00","零时区"),
    EAST_1(1,"GMT+01:00","东一区"),
    EAST_2(2,"GMT+02:00","东二区"),
    EAST_3(3,"GMT+03:00","东三区"),
    EAST_4(4,"GMT+04:00","东四区"),
    EAST_5(5,"GMT+05:00","东五区"),
    EAST_6(6,"GMT+06:00","东六区"),
    EAST_7(7,"GMT+07:00","东七区"),
    EAST_8(8,"GMT+08:00","东八区"),
    EAST_9(9,"GMT+09:00","东九区"),
    EAST_10(10,"GMT+10:00","东十区"),
    EAST_11(11,"GMT+11:00","东十一区"),
    EAST_12(12,"GMT+12:00","东十二区"),
    WEST_1(-1,"GMT-01:00","西一区"),
    WEST_2(-2,"GMT-02:00","西二区"),
    WEST_3(-3,"GMT-03:00","西三区"),
    WEST_4(-4,"GMT-04:00","西四区"),
    WEST_5(-5,"GMT-05:00","西五区"),
    WEST_6(-6,"GMT-06:00","西六区"),
    WEST_7(-7,"GMT-07:00","西七区"),
    WEST_8(-8,"GMT-08:00","西八区"),
    WEST_9(-9,"GMT-09:00","西九区"),
    WEST_10(-10,"GMT-10:00","西十区"),
    WEST_11(-11,"GMT-11:00","西十一区"),
    ;

    TimeZoneEnum(Integer timeZoneId, String code, String desc){
        this.timeZoneId = timeZoneId;
        this.code = code;
        this.desc = desc;
    }

    private Integer timeZoneId;

    private String code;

    private String desc;

    public static TimeZoneEnum of(Integer timeZoneId) {
        if (timeZoneId != null) {
            for (TimeZoneEnum s : values()) {
                if (s.timeZoneId.equals(timeZoneId)) {
                    return s;
                }
            }
        }
        return null;
    }

    public static TimeZoneEnum ofCode(String code) {
        if (code != null) {
            for (TimeZoneEnum s : values()) {
                if (s.code.equals(code)) {
                    return s;
                }
            }
        }
        return null;
    }
}
